using MySql.Data.MySqlClient;
using SqlKata.Compilers;
using SqlKata.Execution;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddTransient<QueryFactory>(service =>
{
    var connection = new MySqlConnection(builder.Configuration.GetConnectionString("Default"));
    var db = new QueryFactory(connection, new MySqlCompiler());
    return db;
});

var app = builder.Build();
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();